<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" th:with="title='发布网球拍',active='publish'">
<header th:replace="back/header::headerFragment(${title},${active})">
    
</header>
<link th:href="@{/back/plugins/tagsinput/jquery.tagsinput.css}" rel="stylesheet"/>
<link th:href="@{/back/plugins/select2.dist.css/select2-bootstrap.css}" rel="stylesheet"/>
<link th:href="@{/back/plugins/toggles/toggles.css}" rel="stylesheet"/>

<link th:href="@{/back/plugins/mditor/css/mditor.min.css}" rel="stylesheet"/>
<link th:href="@{/back/plugins/dropzone/4.3.0/min/dropzone.min.css}" rel="stylesheet">
<style>
    #tags_tagsinput {
        background-color: #fafafa;
        border: 1px solid #eeeeee;
    }

    #tags_addTag input {
        width: 100%;
    }

    #tags_addTag {
        margin-top: -5px;
    }

    .mditor .editor{
        font-size: 14px;
        font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
    }
    .mditor .backdrop, .mditor .textarea, .mditor .viewer{
        font-size: 14px;
    }
    .markdown-body{
        font-size: 14px;
    }
    .note-toolbar {
        text-align: center;
    }

    .note-editor.note-frame {
        border: none;
    }

    .note-editor .note-toolbar {
        background-color: #f5f5f5;
        padding-bottom: 10px;
    }

    .note-toolbar .note-btn-group {
        margin: 0;
    }

    .note-toolbar .note-btn {
        border: none;
    }

    #tennisRacketForm #dropzone {
        min-height: 200px;
        background-color: #dbdde0;
        line-height:200px;
        margin-bottom: 10px;
    }
    #tennisRacketForm .dropzone {
        border: 1px dashed #8662c6;
        border-radius: 5px;
        background: white;
    }
    #tennisRacketForm .dropzone .dz-message {
        font-weight: 400;
    }
    #tennisRacketForm .dropzone .dz-message .note {
        font-size: 0.8em;
        font-weight: 200;
        display: block;
        margin-top: 1.4rem;
    }
/*去除图片预览未选择时默认时的边框*/
    img[src=""],img:not([src]){
        opacity:0;
    }
</style>
<body class="fixed-left">
<div id="wrapper">
    <div th:replace="back/header::header-body"></div>
    <div class="content-page">
        <div class="content">
            <div class="container">
                <div class="row">
                    <div class="col-sm-12">
                        <h4 class="page-title">
                            <th:block th:if="${null != contents}">
                                编辑网球拍
                            </th:block>
                            <th:block th:unless="${null != contents}">
                                发布网球拍
                            </th:block>
                        </h4>
                    </div>
                    <div class="col-md-12">
                    <!-- 上传图片 -->
						    <div class="form-group col-md-12" style="padding: 0 10px 0 0;">
						    	<div th:if="${uploadStatus}" style="color: red"	th:text="${uploadStatus}">上传成功</div>
						    	<!-- <form th:action="@{/admin/uploadFile}" method="post"	enctype="multipart/form-data"> 
						    	
						    		上传文件:&nbsp;&nbsp;<input type="button" value="添加文件" onclick="add()" />
						    		<div id="file" style="margin-top: 10px;" th:value="文件上传区域"></div>
						    		<input id="submit" type="button" value="上传" style="display: none; margin-top: 10px;" />
						    	</form> -->
						    	<a href="javascript:void(0)" onclick="uploadPhoto()">选择图片</a>
						    	<input type="file" id="photoFile" style="display: none;" onchange="upload()">
						    	
						    	<img id="preview_photo" src="" width="200px" height="200px">                           
						    </div>
                        <form id="tennisRacketForm">
                            <input type="hidden" name="id"
                                   th:value="${contents!=null and contents.id!=null}?${contents.id}: ''" id="id"/>
                            <input type="hidden" name="allowComment"
                                   th:value="${contents!=null and contents.allowComment !=null}
                                   ?${contents.allowComment}: true" id="allow_comment"/>
                            <input type="hidden" name="content" id="content-editor"/>
                            <input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/>
                            <div class="form-group col-md-3" style="padding: 0 10px 0 0;">
                                <th:block th:if="${null != contents}">
                                    <input type="text" class="form-control" name="title"
                                           required="required" aria-required="true" th:value="${contents.title}"/>
                                </th:block>
                                <th:block th:unless="${null != contents}">
                                    <input type="text" class="form-control" placeholder="请输入网球拍标题（必须）" name="title"
                                           required="required" aria-required="true"/>
                                </th:block>
                            </div>
                            <!-- 编号 -->
                            <div class="form-group col-md-3" style="padding: 0 10px 0 0;">
                                <th:block th:if="${null != contents}">
                                    <input type="text" class="form-control" name="number"
                                           required="required" aria-required="true" th:value="${contents.number}"/>
                                </th:block>
                                <th:block th:unless="${null != contents}">
                                    <input type="text" class="form-control" placeholder="请输入网球拍编号（必须）" name="number"
                                           required="required" aria-required="true"/>
                                </th:block>
                            </div>
                            <!-- 拍头大小 -->
                            <div class="form-group col-md-3" style="padding: 0 10px 0 0;">
                                <th:block th:if="${null != contents}">
                                    <input type="text" class="form-control" name="headsize"
                                           required="required" aria-required="true" th:value="${contents.headsize}"/>
                                </th:block>
                                <th:block th:unless="${null != contents}">
                                    <input type="text" class="form-control" placeholder="拍头大小" name="headsize"
                                           required="required" aria-required="true"/>
                                </th:block>
                            </div>
                            <!-- 空拍重量 -->
                            <div class="form-group col-md-3" style="padding: 0 10px 0 0;">
                                <th:block th:if="${null != contents}">
                                    <input type="text" class="form-control" name="weight"
                                           required="required" aria-required="true" th:value="${contents.weight}"/>
                                </th:block>
                                <th:block th:unless="${null != contents}">
                                    <input type="text" class="form-control" placeholder="空拍重量" name="weight"
                                           required="required" aria-required="true"/>
                                </th:block>
                            </div>
                            <!-- 平衡点cm -->
                            <div class="form-group col-md-3" style="padding: 0 10px 0 0;">
                                <th:block th:if="${null != contents}">
                                    <input type="text" class="form-control" name="balance"
                                           required="required" aria-required="true" th:value="${contents.balance}"/>
                                </th:block>
                                <th:block th:unless="${null != contents}">
                                    <input type="text" class="form-control" placeholder="平衡点cm" name="balance"
                                           required="required" aria-required="true"/>
                                </th:block>
                            </div>
                            <!-- 长度cm -->
                            <div class="form-group col-md-3" style="padding: 0 10px 0 0;">
                                <th:block th:if="${null != contents}">
                                    <input type="text" class="form-control" name="length"
                                           required="required" aria-required="true" th:value="${contents.length}"/>
                                </th:block>
                                <th:block th:unless="${null != contents}">
                                    <input type="text" class="form-control" placeholder="长度cm" name="length"
                                           required="required" aria-required="true"/>
                                </th:block>
                            </div>
                            <!-- 竖线数量 -->
                            <div class="form-group col-md-3" style="padding: 0 10px 0 0;">
                                <th:block th:if="${null != contents}">
                                    <input type="text" class="form-control" name="stringPatternMain"
                                           required="required" aria-required="true" th:value="${contents.stringPatternMain}"/>
                                </th:block>
                                <th:block th:unless="${null != contents}">
                                    <input type="text" class="form-control" placeholder="竖线数量" name="stringPatternMain"
                                           required="required" aria-required="true"/>
                                </th:block>
                            </div>
                            <!-- 横线数量 -->
                            <div class="form-group col-md-3" style="padding: 0 10px 0 0;">
                                <th:block th:if="${null != contents}">
                                    <input type="text" class="form-control" name="stringPatternCross"
                                           required="required" aria-required="true" th:value="${contents.stringPatternCross}"/>
                                </th:block>
                                <th:block th:unless="${null != contents}">
                                    <input type="text" class="form-control" placeholder="横线数量" name="stringPatternCross"
                                           required="required" aria-required="true"/>
                                </th:block>
                            </div>
                            <!-- 穿线磅数最小值 -->
                            <div class="form-group col-md-3" style="padding: 0 10px 0 0;">
                                <th:block th:if="${null != contents}">
                                    <input type="text" class="form-control" name="recTensionMin"
                                           required="required" aria-required="true" th:value="${contents.recTensionMin}"/>
                                </th:block>
                                <th:block th:unless="${null != contents}">
                                    <input type="text" class="form-control" placeholder="穿线磅数最小值" name="recTensionMin"
                                           required="required" aria-required="true"/>
                                </th:block>
                            </div>
                            <!-- 穿线磅数最大值 -->
                            <div class="form-group col-md-3" style="padding: 0 10px 0 0;">
                                <th:block th:if="${null != contents}">
                                    <input type="text" class="form-control" name="recTensionMax"
                                           required="required" aria-required="true" th:value="${contents.recTensionMax}"/>
                                </th:block>
                                <th:block th:unless="${null != contents}">
                                    <input type="text" class="form-control" placeholder="穿线磅数最大值" name="recTensionMax"
                                           required="required" aria-required="true"/>
                                </th:block>
                            </div>
                            <!-- 材料 -->
                            <div class="form-group col-md-3" style="padding: 0 10px 0 0;">
                                <th:block th:if="${null != contents}">
                                    <input type="text" class="form-control" name="material"
                                           required="required" aria-required="true" th:value="${contents.material}"/>
                                </th:block>
                                <th:block th:unless="${null != contents}">
                                    <input type="text" class="form-control" placeholder="材料" name="material"
                                           required="required" aria-required="true"/>
                                </th:block>
                            </div>
                            <!-- 新旧程度 -->
                            <div class="form-group col-md-3" style="padding: 0 10px 0 0;">
                                <th:block th:if="${null != contents}">
                                    <input type="text" class="form-control" name="newDegree"
                                           required="required" aria-required="true" th:value="${contents.newDegree}"/>
                                </th:block>
                                <th:block th:unless="${null != contents}">
                                    <input type="text" class="form-control" placeholder="新旧程度" name="newDegree"
                                           required="required" aria-required="true"/>
                                </th:block>
                            </div>
                            <div class="form-group col-md-3" style="padding: 0 10px 0 0;">
                                <th:block th:if="${null != contents}">
                                    <input name="tags" id="tags" type="text" class="form-control" th:value="${contents.tags}" />
                                </th:block>
                                <th:block th:unless="${null != contents}">
                                    <input name="tags" id="tags" type="text" class="form-control" placeholder="请输入网球拍标签" />
                                </th:block>
                            </div>
                            <!-- 图片地址 -->
                            <div class="form-group col-md-3" style="padding: 0 10px 0 0;">
                                <th:block th:if="${null != contents}">
                                    <input name="thumbnail" type="text" class="form-control" th:value="${contents.thumbnail}" />
                                </th:block>
                                <th:block th:unless="${null != contents}">
                                    <input name="thumbnail" type="text" class="form-control" placeholder="图片地址" th:value="${imgUrl}" />
                                </th:block>
                            </div>
						    
							<div class="clearfix"></div>
                            <div id="md-container" class="form-group">
                                <textarea id="md-editor" th:utext="${contents!=null and contents.content !=null}?${contents.content}: ''"></textarea>
                            </div>

                 <!--           <div class="form-group col-md-3 col-sm-4">
                                <label class="col-sm-4">开启评论</label>
                                <div class="col-sm-8">
                                    <div th:class="${contents!=null and contents.allowComment!=null }?'toggle toggle-success allow-'+${contents.allowComment}:'toggle toggle-success allow-true'"></div>
                                </div>
                            </div>-->

                            <div class="clearfix"></div>

                            <div class="text-right">
                                <a class="btn btn-default waves-effect waves-light" th:href="@{/admin/tennisRacket}">返回列表</a>
                                <button type="button" class="btn btn-primary waves-effect waves-light" onclick="subArticle('publish');">
                                    保存网球拍
                                </button>
                            </div>
                        </form>
                    </div>
                </div>
                <div th:replace="back/footer :: footer-content"></div>
            </div>
        </div>
    </div>
</div>
<div th:replace="back/footer :: footer"></div>

<script th:src="@{/back/plugins/tagsinput/jquery.tagsinput.min.js}"></script>
<script th:src="@{/back/plugins/jquery-multi-select/jquery.quicksearch.js}"></script>

<script th:src="@{/back/plugins/mditor/js/mditor.min.js}"></script>
<script th:src="@{/back/plugins/multi-select/0.9.12/js/jquery.multi-select.min.js}"></script>
<script th:src="@{/back/plugins/select2/3.4.8/select2.min.js}"></script>
<script th:src="@{//cdn.bootcss.com/jquery-toggles/2.0.4/toggles.min.js}"></script>
<script th:src="@{/back/plugins/dropzone/4.3.0/min/dropzone.min.js}"></script>
<script th:src="@{/back/plugins/to-markdown/3.1.0/to-markdown.min.js}"></script>

<script th:src="@{/back/js/tennisRacket.js}"></script>
<script type="text/javascript">
$(function () {
	var token = $("meta[name='_csrf']").attr("content");
	var header = $("meta[name='_csrf_header']").attr("content");
<!-- 	在 Ajax 请求发送之前将CSRF Token信息绑定在HTTP请求头-->
	$(document).ajaxSend(function(e, xhr, options) {
		xhr.setRequestHeader(header, token);
	});
});
</script>
</body>
</html>